// pages/storage/storage.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 
   */
  doSetStorage: function () {

    // 异步存储
    wx.setStorage({
      key: 'username',
      data: '张三'
    })

    // 同步存储
    wx.setStorageSync('username2', '李四');
  },

  doGetStorage: function(){
    
    // 异步获取
    wx.getStorage({
      key: 'username',
      success(res) {
        console.log(res.data)
      }
    })

    // 同步获取
    let tempUserName = wx.getStorageSync('username2')
    console.log(tempUserName)
  },

  doGetStorageInfo: function(){
    
    wx.getStorageInfo({
      success(res) {
        console.log(res.keys)
        console.log(res.currentSize)
        console.log(res.limitSize)
      }
    })
  }
})